package com.example.sangong.controller;

import com.example.sangong.http.Result;
import com.example.sangong.req.CalCreditParamReq;
import com.example.sangong.req.RoomInfoReq;
import com.example.sangong.utils.CardGroupUtils;
import com.example.sangong.utils.RoomUtils;
import com.example.sangong.utils.UserPlayRecordDbUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/room")
public class RoomController {

    @PostMapping("/info")
    public Result info(@RequestBody RoomInfoReq roomInfoReq) {
        return Result.success(RoomUtils.initRoomInfo(roomInfoReq,10));

    }

    @PostMapping("/calCredit")
    public Result calCredit(@RequestBody CalCreditParamReq req) {
        return Result.success(RoomUtils.calCredit(req));

    }

    @PostMapping("/getPlayRecord")
    public Result getPlayRecord(@RequestBody CalCreditParamReq req) {
        return Result.success(UserPlayRecordDbUtils.getPlayRecordResp(req));

    }

    @PostMapping("/washCard")
    public Result washCard(@RequestBody RoomInfoReq req) {
        CardGroupUtils.washCard(RoomUtils.getCardGroup(req.getRoomNo()));
        return Result.success("");

    }


}
